<% var isDefault =  @CoreUtils.isSysCodeDefault(); %>
<% layout('/layouts/default.html', {title: '商品管理', libs: ['validate','fileupload','ueditor']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(goods.isNewRecord ? '新增商品' : '编辑商品')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${goods}" action="${ctx}/shop/goods/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<#form:hidden path="goodsId"/>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('商品分类')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="category" title="${text('商品分类')}"
									path="category.categoryCode" labelPath="category.categoryName"
									url="${ctx}/shop/goodsCategory/treeData?excludeCode=${goods.category.categoryCode}&shopId=0"
									class="required" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('自定义分类')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:treeselect id="extendCategory" title="${text('自定义分类')}"
									path="extendCategory.categoryCode" labelPath="extendCategory.categoryName"
									url="${ctx}/shop/goodsCategory/treeData?excludeCode=${goods.extendCategory.categoryCode}&shopId=${isDefault?0:user.refCode}"
									class="" allowClear="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required ">*</span> ${text('商品名称')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="goodsName" maxlength="120" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('关键词')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:input path="keywords" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('商品摘要')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="goodsSummary" rows="4" maxlength="255" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('单位')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="unit" maxlength="5" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('品牌')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="brandId" maxlength="5" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('供应商')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="suppliersId" maxlength="5" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('排序')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="goodsSort" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('商品规格')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('商品规格')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<% var items = [{label:'单规格',value:'1'},{label:'多规格',value:'2'}]; %>
								<#form:select id="specSelectId" items="${items}" itemLabel="label" itemValue="value" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div id="specDan">
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('商品编码')}：<i class="fa icon-question "></i></label>
								<div class="col-sm-4">
									<#form:input path="goodsSn" class="form-control "/>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required ">*</span> ${text('市场价')}：<i class="fa icon-question "></i></label>
								<div class="col-sm-4">
									<#form:input path="marketPrice" class="form-control required number"/>
								</div>
							</div>
						</div>
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('成本价')}：<i class="fa icon-question "></i></label>
								<div class="col-sm-4">
									<#form:input path="costPrice" class="form-control number"/>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('商品重量')}：<i class="fa icon-question " title="商品重量克为单位"></i></label>
								<div class="col-sm-4">
									<#form:input path="weight" maxlength="11" class="form-control digits"/>
								</div>
							</div>
						</div>
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('商品体积')}：<i class="fa icon-question " title="商品体积单位立方米"></i></label>
								<div class="col-sm-4">
									<#form:input path="volume" class="form-control number"/>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> ${text('商品库存')}：<i class="fa icon-question "></i></label>
								<div class="col-sm-4">
									<#form:input path="storeCount" class="form-control"/>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div id="specDuo">
					<div class="row">
						<div class="col-xs-6">
							<div class="form-group">
								<label class="control-label col-sm-4" title="">
									<span class="required hide">*</span> <i class="fa icon-question hide"></i></label>
								<div class="col-sm-4">
									努力开发中
								</div>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('商品详情')}</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('图片上传')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:fileupload id="goodsLogo" bizKey="${goods.goodsId}" bizType="goods_logo"
									uploadType="image" class="" readonly="false" maxUploadNum="9"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('视频上传')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:fileupload id="goodsVideo" bizKey="${goods.goodsId}" bizType="goods_video"
									uploadType="media" class="" readonly="false" maxUploadNum="1"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('详细描述')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:ueditor path="goodsContent" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('手机端描述')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="mobileContent" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="form-unit">${text('其他信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('是否上架')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:select path="isOnSale" dictType="sys_yes_no" class="form-control required"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('上架时间')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="onTime" readonly="true" maxlength="20" class="form-control Wdate required"
									dataFormat="datetime" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('运费模板')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-4">
								<#form:input path="templateId" maxlength="11" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注信息')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="500" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('shop:goods:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$(function(){
	$("#specSelectId").on('change',function(){
		var specSelectVal = $("#specSelectId").val();
		if("1"==specSelectVal){
			$("#specDan").show();
			$("#specDuo").hide();
		}else if("2"==specSelectVal){
			$("#specDan").hide();
			$("#specDuo").show();
		}
	});
	$('#specSelectId').val('1').trigger('change');
});
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.page();
				});
			}
		}, "json");
    }
});
</script>